﻿//账户管理-->存量管理详情
//Create By:Cui 2014年9月19日12:09:48

//1.0 加载JqueryDatabase
jQuery(function ($) {
	var oTable1 = $('#sample-table-2').dataTable({
		"aoColumns": [
		  { "bSortable": false },
		  { "bSortable": true },
		  { "bSortable": true },
		  { "bSortable": true },
		  { "bSortable": true },
		  { "bSortable": true },
		  { "bSortable": true },
		  { "bSortable": true },
		  { "bSortable": true },
		  { "bSortable": false },
		],
		oLanguage: {
			"sProcessing": "正在加载中......",
			"sLengthMenu": "每页显示 _MENU_ 条记录",
			"sZeroRecords": "对不起，查询不到相关数据！",
			"sEmptyTable": "表中无数据存在！",
			"sInfo": "当前显示： _START_ 到 _END_ 条，共 _TOTAL_ 条",
			"sInfoFiltered": "数据表中共为 _MAX_ 条记录",
			"sSearch": "",
			"oPaginate": {
				"sFirst": "首页",
				"sPrevious": "上一页",
				"sNext": "下一页",
				"sLast": "末页"
			}
		},
		iDisplayLength: 30,
		bLengthChange: false
	});


	$('table th input:checkbox').on('click', function () {
		var that = this;
		$(this).closest('table').find('tr > td:first-child input:checkbox')
		.each(function () {
			this.checked = that.checked;
			$(this).closest('tr').toggleClass('selected');
		});

	});


	$('[data-rel="tooltip"]').tooltip({ placement: tooltip_placement });
	function tooltip_placement(context, source) {
		var $source = $(source);
		var $parent = $source.closest('table')
		var off1 = $parent.offset();
		var w1 = $parent.width();

		var off2 = $source.offset();
		var w2 = $source.width();

		if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
		return 'left';
	}
})

window.onload = function () {

	//2.0 页面初始化
	//2.1 数量控件
	$('#count').ace_spinner({ value: 0, min: 1, max: 200, step: 1, btn_up_class: 'btn-info', btn_down_class: 'btn-info' })
				.on('change', function () {
				});

	$("td").addClass("tdBorder");

	//2.2 table表头上的样式
	$("#sample-table-2>thead tr>th").attr("style", "font-weight:bold;color:black;text-align:center");


	//2.3 table搜索样式
	$("#sample-table-2_filter label input").attr("placeholder", "搜索(多条件搜索中间用空格隔开)").attr("style", "width:50%");
	$("#sample-table-2_filter label").attr("style", "width:100%");
	$("#sample-table-2_filter").attr("style", "margin-right: -16px;");
	$("#sample-table-2_wrapper .row").first().children().eq(1).attr("style", "margin-top:-12px");
	$("#sample-table-2_wrapper").attr("style", "margin-top:-32px");
	$("#allotStore").attr("style", "margin-top:-4px");

	//2.4 增加表单行间距样式
	$("div .modal-body .row:not(#iconr)").attr("style", "margin-top:7px;").parent().attr("style", "margin-top:-26px");
	$("div .modal-body .row .col-sm-3").attr("style", "margin-top:6px;text-align:right");
	$("div#myModal .modal-body .row i:lt(6)").attr("style", "margin-top:9px;text-align:right;");

	$("#form_field_select_4_chosen").attr("style", "width:f100%");

	//2.5 显示页数一行的样式
	$("#sample-table-2").next().find(".col-sm-6").eq(0).attr("style", "margin-left: -12px;margin-top: 5px;");
	$("#sample-table-2").next().find(".col-sm-6").eq(1).attr("style", "margin-left: 12px;margin-top: 0px;");


	//3     页面功能
	//3.1   刷新
	$("#buflush").click(function () {
		history.go(0);
	});

    //遮罩层div
	$("#bgdiv").attr("style", "display:none");
    //3.2   返回
	$("#goBack").click(function () {
	    history.go(-1);
	});

}